﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        //接受用户输入的一个数n，求n到1所有数的阶乘和；n!+(n-1!)+(n-2)!+……+1! 
        {
            Console.WriteLine("请输入一个正整数");
            int n = int.Parse(Console.ReadLine());
            long sum = 1;
           long fac = 0;
            for (int i = 1; i <= n; i++)
                  {
                sum = sum * i;
                fac += sum;
            }
            Console.WriteLine( n+ "阶乘和为：" + fac);
            Console.ReadKey();
        }
    }
}
